package com.hsq.ndmall.admin.service.impl;

import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hsq.ndmall.common.utils.PageUtils;
import com.hsq.ndmall.common.utils.Query;

import com.hsq.ndmall.admin.dao.SysOauthClientDao;
import com.hsq.ndmall.admin.entity.SysOauthClientEntity;
import com.hsq.ndmall.admin.service.SysOauthClientService;


@Service("sysOauthClientService")
public class SysOauthClientServiceImpl extends ServiceImpl<SysOauthClientDao, SysOauthClientEntity> implements SysOauthClientService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<SysOauthClientEntity> page = this.page(
                new Query<SysOauthClientEntity>().getPage(params),
                getQueryWrapper(params)
        );

        return new PageUtils(page);
    }

    private QueryWrapper getQueryWrapper(Map<String, Object> params){
        QueryWrapper<SysOauthClientEntity> queryWrapper = new QueryWrapper<>();
        if(params.containsKey("client")){
            queryWrapper.lambda().eq(SysOauthClientEntity::getClientId,params.get("client"));
        }
        return queryWrapper;
    }
}
